package cn.genmer.test.security.thread.threadcoreknowledge.stopthread;

/**
 * @program: concurrency_practice
 * @description: run 方法内没有sleep或wait方法时，停止线程.
 * @author: Genmer
 * @create: 2020-10-16 19:03
 **/
public class RightWayStopThreadWithoutSleep implements Runnable{

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new RightWayStopThreadWithoutSleep());
        thread.start();
        Thread.sleep(1000);
        thread.interrupt();
    }
    @Override
    public void run() {
        int num=0;
        while (num<= Integer.MAX_VALUE/2){
            if (num % 10000 == 0){
                System.out.println(num+"是10000的倍数");
            }
            num++;
        }
        System.out.println("任务执行结束");
    }
}
